package com.chen.dal.mysql.post;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.chen.controller.admin.post.vo.PostGetPageReqVO;
import com.chen.controller.admin.post.vo.PostSimpleRespVO;
import com.chen.core.mapper.BaseMapperX;
import com.chen.core.wrapper.LambdaQueryWrapperX;
import com.chen.dal.dateobject.post.PostDO;
import com.chen.pojo.PageResult;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

@Mapper
public interface PostMapper extends BaseMapperX<PostDO> {
    //根据code查找
   default PostDO selectPostByCode(String code){
      return selectOne(new LambdaQueryWrapperX<PostDO>()
               .eqIfPresent(PostDO::getCode,code));
   }
    //根据name查找
    default PostDO selectByName(String name){
       return selectOne(new LambdaQueryWrapperX<PostDO>()
               .eqIfPresent(PostDO::getName,name));
  }
    //分页查询
  default   PageResult<PostDO> selectPostPage(PostGetPageReqVO reqVO){
     return  selectPage(reqVO,new LambdaQueryWrapperX<PostDO>()
               .eqIfPresent(PostDO::getStatus,reqVO.getStatus())
               .likeIfPresent(PostDO::getCode,reqVO.getCode())
               .likeIfPresent(PostDO::getName,reqVO.getName()));
  }
    //根据名字获取岗位的精简列表
    default List<PostDO>  selectListByName(String name){
       return selectList(new LambdaQueryWrapperX<PostDO>()
               .likeIfPresent(PostDO::getName,name));
    }
}
